package com.example.a22310.myapplication.Beans;

import android.content.Intent;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.example.a22310.myapplication.Activity.ActivityDetail;
import com.squareup.picasso.Picasso;

import java.io.Serializable;
import java.util.List;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class Choiceness {

    /**
     * code : 200
     * activitydata : [{"activity_id":9,"activity_name":"22222","activity_place":"22222","activity_time":"0000-00-00 00:00:00","activity_telephone":"111111","activity_free":0,"activity_picture":"01.jpg","activity_intro":"22222","activity_peoplenum":0,"activity_releasetime":"0000-00-00","activity_lovenum":0},{"activity_id":7,"activity_name":"11","activity_place":"11","activity_time":"0000-00-00 00:00:00","activity_telephone":"11","activity_free":0,"activity_picture":"02.jpg","activity_intro":"","activity_peoplenum":0,"activity_releasetime":"0000-00-00","activity_lovenum":111},{"activity_id":8,"activity_name":"11","activity_place":"111","activity_time":"0000-00-00 00:00:00","activity_telephone":"111111","activity_free":0,"activity_picture":"03.jpg","activity_intro":"","activity_peoplenum":0,"activity_releasetime":"0000-00-00","activity_lovenum":1111},{"activity_id":10,"activity_name":"11","activity_place":"111","activity_time":"0000-00-00 00:00:00","activity_telephone":"111111","activity_free":0,"activity_picture":"04.jpg","activity_intro":"","activity_peoplenum":0,"activity_releasetime":"0000-00-00","activity_lovenum":1111},{"activity_id":11,"activity_name":"跑步","activity_place":"东软","activity_time":"2017-10-16 14:20:25","activity_telephone":"852","activity_free":50,"activity_picture":"05.jpg","activity_intro":"你好啊 你好啊 鸟不好","activity_peoplenum":50,"activity_releasetime":"2017-10-09","activity_lovenum":22},{"activity_id":12,"activity_name":"你的ID是v","activity_place":"你好啊","activity_time":"2017-10-09 14:22:12","activity_telephone":"58225252","activity_free":25,"activity_picture":"06.jpg","activity_intro":"哈哈哈哈 你在笑是不是","activity_peoplenum":55,"activity_releasetime":"2017-10-09","activity_lovenum":55}]
     */

    private int code;
    private List<ActivitydataBean> activitydata;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<ActivitydataBean> getActivitydata() {
        return activitydata;
    }

    public void setActivitydata(List<ActivitydataBean> activitydata) {
        this.activitydata = activitydata;
    }

    public static class ActivitydataBean  extends BaseObservable implements Serializable {
        /**
         * activity_id : 9
         * activity_name : 22222
         * activity_place : 22222
         * activity_time : 0000-00-00 00:00:00
         * activity_telephone : 111111
         * activity_free : 0
         * activity_picture : 01.jpg
         * activity_intro : 22222
         * activity_peoplenum : 0
         * activity_releasetime : 0000-00-00
         * activity_lovenum : 0
         */

        public ActivitydataBean() {
        }

        public ActivitydataBean(int activity_id,  String activity_name, String activity_place, String activity_time,
                                String activity_telephone, int activity_free,String activity_picture,String  activity_intro,
                                int activity_peoplenum,String activity_releasetime,int activity_lovenum) {
            this.activity_id = activity_id;
            this.activity_name = activity_name;
            this.activity_place=activity_place;
            this.activity_time =activity_time;
            this.activity_telephone = activity_telephone;
            this.activity_free = activity_free;
            this.activity_picture=activity_picture;
            this.activity_intro=activity_intro;
            this.activity_peoplenum = activity_peoplenum;
            this.activity_releasetime=activity_releasetime;
            this.activity_lovenum=activity_lovenum;
        }
        @BindingAdapter("activity_picture")
        public static void loadInternetImage(ImageView iv, String activity_picture) {
            activity_picture = IMG_URL+activity_picture;
            Picasso.with(iv.getContext()).load(activity_picture).into(iv);
        }

        @Override
        public String toString() {
            return "ActivitydataBean{" +
                    "activity_id='" + activity_id + '\'' +
                    ", activity_name='" + activity_name + '\'' +
                    ", activity_place='" + activity_place + '\'' +
                    "activity_time='" + activity_time + '\'' +
                    ", activity_telephone='" + activity_telephone + '\'' +
                    ", activity_free='" + activity_free + '\'' +
                    "activity_picture='" + activity_picture + '\'' +
                    "activity_intro='" + activity_intro + '\'' +
                    ", activity_peoplenum='" + activity_peoplenum + '\'' +
                    ", activity_releasetime='" + activity_releasetime + '\'' +
                    "activity_lovenum='" + activity_lovenum + '\'' +
                    '}';
        }

        public void onItemClick(View view){
            Intent intent=new Intent(view.getContext(),ActivityDetail.class);
//            往详情传递数据
            Choiceness.ActivitydataBean activitydataBean = new  Choiceness.ActivitydataBean();
            activitydataBean.setActivity_id(getActivity_id());
            activitydataBean.setActivity_name(getActivity_name());
            activitydataBean.setActivity_place(getActivity_place());
            activitydataBean.setActivity_time(getActivity_time());
            activitydataBean.setActivity_telephone(getActivity_telephone());
            activitydataBean.setActivity_free(getActivity_free());
            activitydataBean.setActivity_picture(getActivity_picture());
            activitydataBean.setActivity_intro(getActivity_intro());
            activitydataBean.setActivity_peoplenum(getActivity_peoplenum());
            activitydataBean.setActivity_releasetime(getActivity_releasetime());
            activitydataBean.setActivity_lovenum(getActivity_lovenum());
            intent.putExtra("Choiceness", activitydataBean);
            view.getContext().startActivity(intent);
        }

        @Bindable

        private int activity_id;
        private String activity_name;
        private String activity_place;
        private String activity_time;
        private String activity_telephone;
        private int activity_free;
        private String activity_picture;
        private String activity_intro;
        private int activity_peoplenum;
        private String activity_releasetime;
        private int activity_lovenum;





        public int getActivity_id() {
            return activity_id;
        }

        public void setActivity_id(int activity_id) {
            this.activity_id = activity_id;
        }

        public String getActivity_name() {
            return activity_name;
        }

        public void setActivity_name(String activity_name) {
            this.activity_name = activity_name;
        }

        public String getActivity_place() {
            return activity_place;
        }

        public void setActivity_place(String activity_place) {
            this.activity_place = activity_place;
        }

        public String getActivity_time() {
            return activity_time;
        }

        public void setActivity_time(String activity_time) {
            this.activity_time = activity_time;
        }

        public String getActivity_telephone() {
            return activity_telephone;
        }

        public void setActivity_telephone(String activity_telephone) {
            this.activity_telephone = activity_telephone;
        }

        public int getActivity_free() {
            return activity_free;
        }

        public void setActivity_free(int activity_free) {
            this.activity_free = activity_free;
        }

        public String getActivity_picture() {
            return IMG_URL+activity_picture;
        }

        public void setActivity_picture(String activity_picture) {
            this.activity_picture = activity_picture;
        }

        public String getActivity_intro() {
            return activity_intro;
        }

        public void setActivity_intro(String activity_intro) {
            this.activity_intro = activity_intro;
        }

        public int getActivity_peoplenum() {
            return activity_peoplenum;
        }

        public void setActivity_peoplenum(int activity_peoplenum) {
            this.activity_peoplenum = activity_peoplenum;
        }

        public String getActivity_releasetime() {
            return activity_releasetime;
        }

        public void setActivity_releasetime(String activity_releasetime) {
            this.activity_releasetime = activity_releasetime;
        }

        public int getActivity_lovenum() {
            return activity_lovenum;
        }

        public void setActivity_lovenum(int activity_lovenum) {
            this.activity_lovenum = activity_lovenum;
        }
    }
}
